import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

import { NbMenuItem } from '@nebular/theme';
import { MENU_ITEMS } from '../../../pages/pages-menu'
import { ToasterConfig } from 'angular2-toaster';

import 'style-loader!angular2-toaster/toaster.css';

@Component({
  selector: 'ngx-header',
  styleUrls: ['./header.component.scss'],
  templateUrl: './header.component.html',
})
export class HeaderComponent implements OnInit {

  // 菜单项
  menuItems: NbMenuItem[] = MENU_ITEMS;
  today = Date.now();
  currentTarget : string = "one";

  config: ToasterConfig;

  constructor(private router: Router) {}

  ngOnInit() {
    this.config = new ToasterConfig({
      positionClass: 'toast-bottom-right',
      timeout: 5000,
      newestOnTop: true,
      tapToDismiss: true,
      preventDuplicates: false,
      animation: 'fade',
      limit: 5,
      showCloseButton: true
    });
  }

  routeTarget(menu: NbMenuItem) {
    this.currentTarget = menu.target;
    if (menu.link) {
      this.router.navigate([menu.link]);
    }
  }

}
